package sk.fiit.vppj.eventmanager.data;

import java.util.Collections;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Data class which holds evaluation information for administrator. Class is immutable.
 * 
 * @author Marek
 * 
 */
public final class ProjectAdminEval {
	private Map<String, Object> data = null;
	private final static Logger log = Logger.getLogger( Project.class.getName() );

	public ProjectAdminEval() {
	}

	public void setData(Map<String, Object> data) {
		this.data = Collections.unmodifiableMap( data );
		if( this.data == null ) {
			log.log( Level.WARNING, "Project evaluation was not set!" );
			throw new NullPointerException( "No data set in ProjectAdminEval" );
		}
	}

	public final int getCriteriaId() {
		if( this.data.get( "IDProject_criteria" ) == null ) {
			return 0;
		}
		return Integer.parseInt( this.data.get( "IDProject_criteria" ).toString() );
	}

	public final int getPoints() {
		if( this.data.get( "points" ) == null ) {
			return 0;
		}
		return ( int ) Double.parseDouble( this.data.get( "points" ).toString() );
	}

	public final int getMaxPoints() {
		if( this.data.get( "total_points" ) == null ) {
			return 0;
		}
		return ( int ) Double.parseDouble( this.data.get( "total_points" ).toString() );
	}

	public String getCriteriaName() {
		if( this.data.get( "criteriaName" ) == null ) {
			return null;
		}
		return this.data.get( "criteriaName" ).toString();
	}

	public String getJudgeName() {
		if( this.data.get( "judgeName" ) == null ) {
			return null;
		}
		return this.data.get( "judgeName" ).toString();
	}

	// TODO override hashcode and equals
}
